Placeholders with Format Definition
The output text of an element can display the value of a variable by means of a placeholder (%) with a format definition. When the text is displayed, the value of the variable is inserted instead of the placeholder. The data type in the format definition and of the variable must be identical.
The displayed string is listed in the element property. The variable is listed in the Text variable property.
Visualization users can specify a text in an element, in which the text, for example, is stored and displayed as a text output variable. The user input must correspond to the input format. The data type of the text output variable must correspond to the data type which is defined for the input format.
The format definition for the input text is located in the Input configuration dialog, in Text input, in the Write Variable input action. The variable is listed in the Text variable property.
Integer
The format definition for an integer has the following format:
% <flags> <minimum number of digits> <type>
Recommended data types: BYTE | WORD | DWORD | LWORD | SINT | USINT | INT | UINT | DINT | UDINT | LINT | ULINT
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<flags> | Optional and combinable | Code: Property: Text variable: | |
|
| Alignment left-justified, with respect to the minimum width of the number (specified in minimum number of digits) | Property: Text: |
|
| Output always with a sign | Property: Text: Output: |
|
| Places are filled with a 0 until the minimum number of places (including the sign) is reached | Property: Text: |
|
| Causes the value to be displayed as an integer with thousands separators. | Code snippet: iValue : INT := 4321; Property: Text: Output: |
<minimum number of digits> |
| Optional Minimum number of places |
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<type> | Required | ||
|
| Output as an integer decimal number | Code: Property: Text: Property: Text variable: Output: |
| Code: Property: Text: Property: Text variable: Output: | ||
|
| Output as unsigned, integer binary number without a prefix | Code: Property: Text: Property: Text variable: Output: |
|
| Output as unsigned, integer octal number without a prefix | Code: Property: Text: Property: Text variable: Output: |
|
| Output as an unsigned 32-bit hexadecimal number with the digits a–f (lowercase) without a prefix and without a separator | Code: Property: Text: Property: Text variable: Output: |
|
| Output as an unsigned 32-bit hexadecimal number with the digits A–F (uppercase) without a prefix and without a separator | Code: Property: Text: Property: Text variable: Output: |
|
| Output as an unsigned 64-bit hexadecimal number with the digits a–f (lowercase) without a prefix and without a separator Note: Recommended data types: | Code: Property: Text: Property: Text variable: Output: |
|
| Output as an unsigned 64-bit hexadecimal number with the digits A–F (uppercase) without a prefix and without a separator Recommended data types: | Code: Property: Text: Property: Text variable: Output: |
|
| Output as an unsigned integer decimal number Recommended data types: | Code: Property: Text: Property: Text variable: Output: |
Floating-point number in fixed-point notation
Floating-point numbers can be displayed as a decimal number in fixed-point notation. The format definition for this has the following format:
% <flags> <minimum number of digits> . <accuracy> f
Recommended data types for this kind of placeholder variable: REAL | LREAL
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<flags> | Optional and combinable | ||
|
| Alignment left-justified, with respect to the minimum number of digits | |
|
| Always with a sign, also for positive numbers | Code: Property: Text: Property: Text variable: Output: |
|
| Places are filled with a 0 until the minimum number of places (including the sign and decimal point) is reached | Code: Property: Text: Property: Text variable: Output: |
|
| Causes the number to be displayed as a floating-point number with thousands separators. | Code snippet: rValue : REAL:= 6543,21; Property: Text: Property: Text variable: Output: |
<minimum number of digits> . <accuracy> | Optional When not specified, the number is output in standard format 1.6 | ||
<minimum number of digits> |
| Minimum number of places including the sign and decimal point Example: 12 | Code: Property: Text: Property: Text variable: Output: |
<accuracy> |
| Accuracy in places and the decimal point Example: 3 | Code: Property: Text: Property: Text variable: Output: |
|
| Required Format identifier for decimal display with the decimal point | Code: Property: Text: Property: Text variable: Output: |
Floating-point number in exponential notation
Floating-point numbers can be displayed in standardized exponential notation with base 10. The format definition for exponential notation has the following format:
% <flags> <minimum number of digits> . <accuracy> <type>
Recommended data types for this kind of placeholder variable: REAL | LREAL
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<flags> | Optional and combinable | ||
|
| Alignment left-justified, with respect to the minimum number of digits | |
|
| Always with a sign, also for positive numbers | Code: Property: Text: Property: Text variable: Output: |
|
| Places are filled with a 0 until the minimum number of places (including the sign and decimal point) is reached | Code: Property: Text: Property: Text variable: Output: |
<minimum number of digits> . <accuracy> | Optional When not specified, the mantissa is output in standard format 1.6 | ||
<minimum number of digits> |
| Minimum number of places, including the sign (for mantissa and exponent), decimal point, and exponents ( Example: 12 | Code: Property: Text: Property: Text variable: Output: |
<accuracy> |
| Accuracy of the mantissa in places and the decimal point Example: 3 | Code: Property: Text: Property: Text variable: Output: |
<type> | Required | ||
|
| Display with | Code: Property: Text: Property: Text variable: Output: |
|
| Display with | Code: Property: Text: Property: Text variable: Output: |
Time in integers
Compatibility Notice
In order to get the usual display, in V3.5 SP17 and higher, as a rule three digits are used for the output of fractions of a second (ms/µs/ns). Example: In %t[dd-HH:mm:ss:ms], ms is specified with three digits for the milliseconds. For this purpose, the two-digit ms number is prepended with a zero.If a two-digit output is desired (like before V3.5 SP17), then a special compiler define must be set in the compiler properties of the application: VISU_MILLISEC_NOLEADING_ZERO.
If the output text in the element property contains the placeholder %t with an identification for a time unit, then a time, a time duration, or a time interval is output. The placeholder variable is assigned in the Text variable property.
The placeholder for a time per time unit has the following format:
%t[ <text> <time in unit> <text> ]
Recommended data types: TIME, LTIME
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<time in unit> | Required Identification for a time unit Filters from the time value the complete number of the specified time unit (days, hours, minutes, seconds, milliseconds) For 64-bit time values, also microseconds and nanoseconds | ||
Valid for the following examples: Code: Property: Text variable: | |||
|
| Number of days, without a prepended zero | Property: Text: Output: |
|
| Number of whole days, with a prepended zero | Property: Text: Output: |
|
| Number of hours (0–23) | Property: Text: Output: |
|
| Number of hours (00–23) | Property: Text: Output: |
|
| Number of hours (0–23) | Property: Text: Output: |
|
| Number of hours (00–23) | Property: Text: Output: |
|
| Number of minutes (0–59), without leading zero | Property: Text: Output: |
|
| Number of minutes (00–59), with leading zero | Property: Text: Output: |
|
| Number of seconds (00–59), without leading zero | Property: Text: Output: |
|
| Number of seconds (00–59), with leading zero | Property: Text: Output: |
|
| Number of fractional seconds, in milliseconds (0–999) | Property: Text: Output: |
|
| Number of fractional seconds, in microseconds (0–999) Only for data type | Property: Text: Output: Note: Overflow is permitted in the greatest time unit of a definition. |
|
| Number of fractional seconds, in nanoseconds (0–999) Only for data type | Property: Text: Output: Note: Overflow is permitted in the greatest time unit of a definition. |
<text> |
| Optional Strings, which are specified inside of brackets, are included in the output Note: If a string should be output, which corresponds to an identification for a time unit or which contains identifications for time units, then the string must be enclosed in single straight quotation marks. | Property: Text: Output: Property: Text: Output: |
Inside the brackets, identifications for time units can occur any number of times and can be interchanged with any strings.
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
| Time format for all time units, with the usual separator in between | Property: Text: Output: | |
| Format with additional strings which should be output, without considering the identifications for time units These kinds of strings are enclosed in simple straight quotation marks. | Property: Text: Output: |
Time as decimal number
Recommended data types: TIME, LTIME
In the format definition, the time duration <time in unit> can be identified with the decimal place identification <number of decimal places>. The result is that the time duration is formatted as a decimal number (with decimal places) in the specified time unit. That is possible for the following time formats: HH | H | hh | h| mm | m | ss | s | ms |us | ns. This can be useful for user input.
The placeholder for a time span as a decimal number has the following format:
%t[ <time in unit> <number of decimal places>]
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<time in unit> | Required Identification of a time unit which formats the time value in the specified time unit (days, hours, minutes, seconds, milliseconds) as a decimal number For 64-bit time values, also microseconds and nanoseconds | ||
<number of decimal places> | Required Maximum number of decimal places ( Note: Even if decimal places are not desired for the input or display, at least the number | ||
The requirements apply for the following examples: Code: Property: Text variable: | |||
|
| Time value (in hours) as a decimal number Number of hours (0–23) Example: 4 | Property: Text: User input: Time value: |
|
| Time value (in minutes) as a decimal number Example: 2 | User input: Time value |
|
| Time value (in seconds) as a decimal number Example: 3 | User input: Time value |
| Example: 0 | User input: Time value | |
|
| Time value (in milliseconds) as a decimal number Example: 3 | User input: Time value |
|
| Time value (in microseconds) as a decimal number Example: 3 | User input: Time value |
|
| Time value (in nanoseconds) as a decimal number Example: 0 | User input: Time value |
System time
If a variable is not assigned to a placeholder with a format definition, then the system time is output.
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
|
| Output of the current system time Requirement: No variable is specified below the Text variable property. | Property: Text: Property: Text variable: blank Output: |
|
| Optional Output of the offset of the local system time as universal time (UTC) | Property: Text: Depending on the UTC variable
|
Tip
You can programmatically switch the local time zone of the system time to universal time (UTC).
When the variable VisuElems.Visu_DateTime.DisplayUTC is set to TRUE, the system time is displayed as universal time (UTC). By default, the variable VisuElems.Visu_DateTime.DisplayUTC is set to FALSE so that the system time is displayed in the local time zone.
For the display of date and time values, you can extend the respective format string with the time zone code Z. For an output in local system time, the offset is then displayed in universal time (UTC). For example, dd:MM:yyyy HH:mm:ss:ms:Z outputs 01.08.2021 12:00:00:001:+02:00. When universal time (UTC) is displayed, the UTC code is also displayed. 01.08.2021 10:00:00:001:Z
Date and Time
Compatibility Notice
In order to get the usual display, in V3.5 SP17 and higher, as a rule three digits are used for the output of fractions of a second (ms/µs/ns). Example: In %t[dd-HH:mm:ss:ms], ms is specified with three digits for the milliseconds. A zero is prepended to the two-digit ms number.If a two-digit output is desired (like before V3.5 SP17), then a special compiler define must be set in the compiler properties of the application: VISU_MILLISEC_NOLEADING_ZERO.
Recommended data types for date and time definitions: DATE, DATE_AND_TIME, DT, LDATE, LDATE_AND_TIME, LDT, LTOD, TIME_OF_DAY, TOD
By default, the names of the days and months are displayed in English. When localized texts are used, the System text list must be supplemented. This text list is automatically created in the POUs view when the %t placeholder is used. The English terms must be used as the IDs here. The localization can be done for both the abbreviated names and full names.
The format string for a date and time definition has the following format:
%t[ <date and time unit> ]
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<date and time unit> | Required Identification for date and time units Filters from the time value (data type: date and time) the value for the specified unit (year, month, day, hour, minute, milliseconds) For 64-bit date and time values, also microseconds and nanoseconds | ||
|
| Year with century | Code: Property: Text: Property: Text variable: Output: |
|
| Year without century (00–99) | Code: Property: Text: Property: Text variable: Output: |
|
| Year without century (0–99) | Code: Property: Text: Property: Text variable: Output: |
|
| Month as full name | Code: Property: Text: Property: Text variable: Output: |
|
| Month as abbreviated name | Code: Property: Text:: Property: Text variable: Output: |
|
| Month as number (01–12) | Code: Property: Text:: Property: Text variable: Output: |
|
| Month as number (1–12) | Code: Property: Text: Property: Text variable: Output: |
|
| Day of week as number (1 = Monday – 7 = Sunday) | Code: Property: Text:: Property: Text variable: Output: |
|
| Day of week as full name | Code: Property: Text:: Property: Text variable: Output: |
|
| Day of week as abbreviated name | Code: Property: Text:: Property: Text variable: Output: |
|
| Day of month as number (01–31) | Code: Property: Text: Property: Text variable: Output: |
|
| Day of month as number (1–31) | Code: Property: Text:: Property: Text variable: Output: |
|
| Day of year as number (001–366) | Code: Property: Text: Property: Text variable: Output: |
|
| Hour in 24-hour format (00–23) Example
| Code: Property: Text: Property: Text variable: Output: |
|
| Hour in 12-hour format (01–12) Example
| Code: Property: Text: Property: Text variable: Output: |
|
| Abbreviation A or P in 12-hour format A for P for Example
| Code: Property: Text: Property: Text variable: Output: |
|
| Abbreviation AM or PM in 12-hour format AM for PM for Example
| Code: Property: Text: Property: Text variable: Output: |
Inside the brackets, identifications for date and time units can occur any number of times and can be interchanged with any strings.
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
| Date and day of the week with separators in between | Code: Property: Text: Property: Text variable: Output: | |
| Time of day | Code: Property: Text: Property: Text variable: Output: | |
| If strings should be output which correspond to a format definition, then these must be represented in single straight quotation marks. | Property: Text: Output: |
Text
Recommended data types of the placeholder variable: STRING, WSTRING
The format definition for strings and strings have the following format:
% <type>
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
<type> | |||
|
| Output of single character in ASCII character set | Code: Property: Text: Property: Text variable: Output: |
|
| Output of string Recommended data types: | Code: Property: Text: Property: Text variable: Output: When UTF-8 encoding is enabled for the For more information, see the following: Dialog: Project Settings: Compile options |
Percent sign
Format definition for output of a percent sign
Syntax | Example | Description | Example in Visualization |
|---|---|---|---|
|
| Output of the percent sign | With a placeholder variable: Code: Property: Text: Property: Text variable: Output: |
Property: Text: Output: |